/*
   mainwin.h
*/

#pragma warning(disable:4996)

#include "resource.h"

#include "SerialEx.h"
#pragma comment(lib, "Serial.lib")

#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020a
#endif

#define MAINWIN_CLASS_NAME "arduino_server"
#define MAINWIN_STYLE (WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN)

#define MAINWINDOW_WIDTH 250
#define MAINWINDOW_HEIGHT 250

class serialCom :public CSerialEx
{
public:
  serialCom(HWND hwnd);
  ~serialCom(){};
  bool enableCom;
  void ComOpen(int p, int dlen);
  void OnEvent(EEvent eEvent, EError eError);

protected:
  int comport_no;
  int bufp;
  int pdata_len;
  unsigned char buf[256], pdata[256];
  HWND hdlg;
};

class mainWin
{
public:
  mainWin(HINSTANCE hAppInstance);
  ~mainWin();
  static LRESULT CALLBACK WndProcMain(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  static LRESULT CALLBACK DlgProcCtrl(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

  serialCom *arduino;

protected:
  void registerClass();
  void unregisterClass();

  HINSTANCE m_hAppInstance;
  HWND m_hwnd, m_hdlg;
};


